package com.fire8.dolphin.ui.plan;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

import com.fire8.dolphin.ui.R;

/**
 * 康复计划模板
 * <功能详细描述>
 *
 * @author  wangchd
 * @version [版本号,2013-1-14]
 * @see     [相关类/方法]
 * @since   [产品/模块]
 */
public class PlanTemplateActivity extends Activity
{
    
    //private List<String> lvCheckdata = new ArrayList<String>();
    Map<String,String> hashMap = new HashMap<String,String>();
    
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.plan_template);

        
        ListView lv1 = (ListView)findViewById(R.id.lv_plan_templete);
        ArrayAdapter adapter = ArrayAdapter.createFromResource(this,
                R.array.spin_alarm_cycle,
                android.R.layout.simple_list_item_multiple_choice);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        lv1.setAdapter(adapter);
        
        lv1.setOnItemClickListener(new OnItemClickListener()
        {

            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                    long arg3)
            {
                String title = ((TextView)arg1).getText().toString();
                if(hashMap.containsKey(title))
                    hashMap.remove(title);
                else
                    hashMap.put(title,title);
              //lvCheckdata.add(((TextView)arg1).getText().toString());
            }
        });
        Button btNextRight = (Button)findViewById(R.id.bt_next_right);
        btNextRight.setOnClickListener(new OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                Intent data = new Intent();
                List<String> lvCheckdata = new ArrayList<String>();
                lvCheckdata.addAll(hashMap.values());
                data.putStringArrayListExtra("lvList", (ArrayList<String>)lvCheckdata);
                setResult(RESULT_OK, data);
                finish();
            }
        });
    }

}
